package com.listener;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * Copyright (c)  by www.leya920.com
 * All right reserved.
 * Create Date: 2021-01-03 14:46
 * Create Author: xuweiwei
 * File Name: MyApplicationRunListener.java
 * Last version:  1.0
 * Function: //TODO
 * Last Update Date: 2021-01-03 14:46
 * Last Update Log:
 * Comment: //TODO
 **/
@Order(10)
public class MyApplicationRunListener implements SpringApplicationRunListener {

	// 必须有这个构造函数，否则无法使用或者构建不成
	public MyApplicationRunListener(SpringApplication application, String[] args) {

		System.out.println("MyApplicationRunListener init");
	}


	@Override
	public void starting() {
		System.out.println("MyApplicationRunListener starting");
	}

	@Override
	public void environmentPrepared(ConfigurableEnvironment environment) {
		System.out.println("MyApplicationRunListener environmentPrepared");
	}

	@Override
	public void contextPrepared(ConfigurableApplicationContext context) {
		System.out.println("MyApplicationRunListener contextPrepared");
	}

	@Override
	public void contextLoaded(ConfigurableApplicationContext context) {
		System.out.println("MyApplicationRunListener contextLoaded");
	}

	@Override
	public void started(ConfigurableApplicationContext context) {
		System.out.println("MyApplicationRunListener started");
	}

	@Override
	public void running(ConfigurableApplicationContext context) {
		System.out.println("MyApplicationRunListener running");
	}

	@Override
	public void failed(ConfigurableApplicationContext context, Throwable exception) {
		System.out.println("MyApplicationRunListener failed");
	}
}
